import org.w3c.dom.css.Counter;

import  java.util.*;
public class Test {
    public static void main(String[] args) {
        Object object = new Object();
        Thread t1 = new Thread(()->{
           synchronized (object){
               System.out.println("wait之前");
               try {
                   object.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("wait之后");
           }
        });
        Thread t2 = new Thread(()->{
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (object){
                System.out.println("进行通知");
                object.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
/*    public volatile  static int isQuit = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while(isQuit==0){

            }
            System.out.println("t1退出");
        });
        t1.start();
        Thread t2 = new Thread(()->{
            System.out.println("请输入isQuit");
            Scanner scanner = new Scanner(System.in);
            isQuit = scanner.nextInt();
        });
        t2.start();
    }*/
  /*  Thread t1 = new Thread(()->{
        synchronized (locker1){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        synchronized (locker2){
            System.out.println("t1加锁成功");
        }
    });
    Thread t2 = new Thread(()->{
        synchronized (locker2){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (locker1){
                System.out.println("t2加锁成功");
            }
        }
    });
        t1.start();
                t2.start();*/
/*    public static int count = 0;
    public static void increase(){
        synchronized(Counter.class){
            count++;
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            for (int i = 0; i <5000 ; i++) {
                increase();
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i <5000 ; i++) {
                increase();
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(count);
    }*/
 /*   public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while(true){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        System.out.println(t.getState());
        t.start();
        for (int i = 0; i < 5; i++) {
            System.out.println(t.getState());
            Thread.sleep(1000);
        }
    }*/
/*
    private static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("线程工作中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("线程工作结束");
            }
        });
        t.start();
        Thread.sleep(5000);
        System.out.println("让t线程结束");
        t.interrupt();
    }*/
